#include "comm.h"

int main() {
    int fd = open(FILE_NAME, O_WRONLY);
    if(fd < 0) {
        perror("open error");
        exit(1);
    }
    int fdin = open("test.txt", O_RDONLY);
    if(fdin < 0) {
        perror("open error");
        exit(2);
    }
    char message[256];
    while(true) {
        ssize_t s = read(fdin, message, sizeof(message));
        if(s > 0) {
            write(fd, message, s);
        }else if(s == 0) {
            printf("read end of test.txt");
            break;
        }else {
            printf("read error");
            break;
        }
    }
    close(fd);
    close(fdin);
    return 0;
}
